package com.chifuyu.control;

import com.chifuyu.master.Knight;

import java.util.Scanner;

import static com.chifuyu.Runner.TEAMS;

public class StartWith {

    public static void titleAndStory() {
        int times = 0;
        System.out.println("————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————");
        System.out.println("|   ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————   |");
        System.out.println("|  |     ————————————                                                                                                                   |  |");
        System.out.println("|  |     /           /      ——                                                                                                          |  |");
        System.out.println("|  |   —————   ————       / /                                                                                                           |  |");
        System.out.println("|  |        /  /          / /                                                                                                           |  |");
        System.out.println("|  |       /  /          / /                                                                                                            |  |");
        System.out.println("|  |      /  /    ==    / /     / —— \\   / == >                                                                                         |  |");
        System.out.println("|  |     /  /  //  //  | / __  (  ==  )  \\ == \\               / = >                                                                     |  |");
        System.out.println("|  |    /__/    ==  *  \\_==_/   \\ __ >   < == /      ===     //                                                                         |  |");
        System.out.println("|  |                                               //  //  == ==                                                                        |  |");
        System.out.println("|  |                                                ===     //                                                                          |  |");
        System.out.println("|  |                                                       //          UNDEFINED    UNDEFINED    UNDEFINED    UNDEFINED    UNDEFINED    |  |");
        System.out.println("|  |                                                   < = /           UNDEFINED    UNDEFINED    UNDEFINED    UNDEFINED    UNDEFINED    |  |");
        System.out.println("|  |                                                                   UNDEFINED    UNDEFINED    UNDEFINED    UNDEFINED    UNDEFINED    |  |");
        System.out.println("|  |                                                                   UNDEFINED    UNDEFINED    UNDEFINED    UNDEFINED    UNDEFINED    |  |");
        System.out.println("|  |                                                                   UNDEFINED    UNDEFINED    UNDEFINED    UNDEFINED    UNDEFINED    |  |");
        System.out.println("|   —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————  |");
        System.out.println("————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————");
        System.out.println("                                                                                                                                            ");
        System.out.println("                                                    < Input 'START' to Start the Game! >                                                    ");
        System.out.println("                                                                                                                                            ");

        while (times < 3) {
            Scanner scanner = new Scanner(System.in);
            String start = scanner.nextLine();
            if (start.equals("START")) {
                tallStory();
            } else {
                times++;
            }
        }
    }

    private static void tallStory() {
        System.out.print("\033[H\033[2J");
        System.out.flush();
        System.out.println("story");
        sleep(3);
        System.out.println("story");
        sleep(3);
        System.out.println("story");
        sleep(3);
        System.out.println("story");
        sleep(3);
        System.out.println("story");
        sleep(3);
        System.out.println("story");
        sleep(3);
        System.out.println("story");
        sleep(3);
    }

    public static void initTeams() {
//        System.out.println("---------------------------- Master Pool: 1. Knight 2. Wizard 3. Archer ----------------------------");
//        playerOneChooseMaster();
//        System.out.println("------------------------------------------- CHOOSE OVER! -------------------------------------------");
        TEAMS.add(new Knight("Knight"));
    }

    private static void sleep(int min) {
        try {
            Thread.sleep(1000L * min);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
